var app = getApp(),
  $ = require("../../utils/httpHelper.js")
Page({
  data: {
    // tab切换  
    currentTab: 0,
    objarr: [],
    page: 1,
    pagesize: 10,
    totalpage: 0,//最大页数,
    status: 'WAIT_BUYER_PAY',
    height:0,
    nomore: true,
  },
  onLoad: function (options) {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        that.setData({ height: res.windowHeight})
      }
    })
    if (!app.check_empty(options.catid)) {
      let params = {
        catid: options.catid,
        page: this.data.page,
        page_size: this.data.pagesize
      }
      $.httpPost('news_list', params, (data, err) => {
        this.setData({
          objarr: data.data.lists,
          totalpage: data.data.total_page
        })
      })
    }
    
   
    
  },
  
 
  //滑动到底部 上拉加载
  scrollBottom: function () {
    this.data.page++
    if (this.data.page > this.data.totalpage) {
      this.setData({
        nomore: false
      })
    } else {
      let params = {
        catid: '1663',
        page: this.data.page,
        page_size: this.data.pagesize
      }
      $.httpPost('news_list', params, (data, err) => {
        let arr = this.data.objarr;
        for (let item of data.data.lists) {
          arr.push(item);
        }
        this.setData({
          objarr: arr
        })
      })


    }

  },
  todetail(e){
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/zixun/zxdetail?id='+id,
    })
  }
    
})  